-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix typeassert error in read_refs #170
Conversation
Hmmmm so now it passes on some platform/version combos and fails on others. Are these fails related to this patch, or due to other causes? |
src/JLD.jl
Outdated
end | ||
return out | ||
else | ||
throw(e) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rethrow would preserve the backtrace
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed throw(e)
to rethrow(e)
!
An assignment like this should cause it to convert one type to the other, and not throw a Type Error |
I'm closing this PR for now; I'll reopen if the issue reappears! |
This patch fixes a typeassert error that arises in the read_refs function in src/JLD.jl:482. The error arises when, for example,
eltype(out)
isArray{Array,1}
buttypeof(read_ref(f, refs[i]))
isArray{Array{Float32,1},1}
.Array{Float32,1}
is a subtype ofArray
, butArray{Array{Float32,1},1}
is not a subtype ofArray{Array,1}
because in Julia type parameters are invariant.Thus, if you try to assign a value of type
Array{Array{Float32,1},1}
toout[i]
, butout[i]
is expecting a value of typeArray{Array,1}
, then a TypeAssert is thrown.The simple workaround is to change the type of
out
fromArray{T}
toArray{Any}
.Fixes #154 in this repo as well as pluskid/Mocha.jl#219 and pluskid/Mocha.jl#229. (All are the same issue.)